package gestion_des_note;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;

public class Consulter_Etudiant extends JDialog {
  private JLabel [] jlblNote1= new JLabel[3];
  private JPanel jPanel1 = new JPanel();
  private JLabel jlblMatricule = new JLabel();
  private JLabel jLabel6 = new JLabel();
  private JLabel jLabel5 = new JLabel();
  private JLabel jLabel4 = new JLabel();
  private JLabel jLabel3 = new JLabel();
  private JLabel jLabel2 = new JLabel();
  private JLabel jLabel1 = new JLabel();
  private JLabel jlblNom = new JLabel();
  private JLabel jlblPrénom = new JLabel();
  private JLabel jlblFilier = new JLabel();
  private JLabel jlblGroup = new JLabel();
  private JPanel jPanel2 = new JPanel();
  private JButton jbtnRetour = new JButton();
Classe cls = new Classe();
  public Consulter_Etudiant() {
    try {
      jbInit();
    }
    catch(Exception e) {
      e.printStackTrace();
    }
  }
  private void jbInit() throws Exception {
    jPanel1.setLayout(null);
    jlblMatricule.setFont(new java.awt.Font("Dialog", 1, 13));
    jlblMatricule.setBorder(BorderFactory.createLineBorder(Color.black));
    jlblMatricule.setOpaque(true);
    jlblMatricule.setBounds(new Rectangle(184, 51, 131, 20));
    jLabel6.setFont(new java.awt.Font("Dialog", 1, 13));
    jLabel6.setForeground(Color.red);
    jLabel6.setText("Notes          :");
    jLabel6.setBounds(new Rectangle(79, 197, 92, 23));
    jLabel5.setFont(new java.awt.Font("Dialog", 1, 13));
    jLabel5.setForeground(Color.red);
    jLabel5.setText("Niveau          :");
    jLabel5.setBounds(new Rectangle(79, 170, 93, 20));
    jLabel4.setFont(new java.awt.Font("Dialog", 1, 13));
    jLabel4.setForeground(Color.red);
    jLabel4.setText("Filiere           :");
    jLabel4.setBounds(new Rectangle(80, 144, 97, 19));
    jLabel3.setFont(new java.awt.Font("Dialog", 1, 13));
    jLabel3.setForeground(Color.red);
    jLabel3.setText("Prénom        :");
    jLabel3.setBounds(new Rectangle(78, 115, 99, 18));
    jLabel2.setBackground(SystemColor.inactiveCaptionBorder);
    jLabel2.setFont(new java.awt.Font("Dialog", 1, 13));
    jLabel2.setForeground(Color.red);
    jLabel2.setText("Nom             :");
    jLabel2.setBounds(new Rectangle(81, 84, 100, 15));
    jLabel1.setFont(new java.awt.Font("Dialog", 1, 13));
    jLabel1.setForeground(Color.red);
    jLabel1.setText("Matricule      :");
    jLabel1.setBounds(new Rectangle(81, 51, 95, 17));
    jlblNom.setFont(new java.awt.Font("Dialog", 1, 13));
    jlblNom.setBorder(BorderFactory.createLineBorder(Color.black));
    jlblNom.setOpaque(true);
    jlblNom.setBounds(new Rectangle(184, 79, 132, 19));
    jlblPrénom.setFont(new java.awt.Font("Dialog", 1, 13));
    jlblPrénom.setBorder(BorderFactory.createLineBorder(Color.black));
    jlblPrénom.setOpaque(true);
    jlblPrénom.setBounds(new Rectangle(184, 109, 133, 22));
    jlblFilier.setFont(new java.awt.Font("Dialog", 1, 13));
    jlblFilier.setBorder(BorderFactory.createLineBorder(Color.black));
    jlblFilier.setOpaque(true);
    jlblFilier.setBounds(new Rectangle(185, 140, 133, 21));
    jlblGroup.setFont(new java.awt.Font("Dialog", 1, 13));
    jlblGroup.setBorder(BorderFactory.createLineBorder(Color.black));
    jlblGroup.setOpaque(true);
    jlblGroup.setBounds(new Rectangle(185, 168, 133, 20));
    jPanel1.setBackground(Color.white);
    jPanel1.setFont(new java.awt.Font("Dialog", 1, 13));
    jPanel2.setBackground(Color.white);
    jPanel2.setBounds(new Rectangle(186, 205, 134, 91));
    for(int i=0;i<3;i++){
      jlblNote1[i]=new JLabel();
      jlblNote1[i].setPreferredSize(new Dimension(76, 22));
      jlblNote1[i].setFont(new java.awt.Font("Dialog", 1, 12));
      jlblNote1[i].setBackground(Color.lightGray);
      jlblNote1[i].setBorder(BorderFactory.createLineBorder(Color.black));
      jPanel2.add(jlblNote1[i]);
    }
    this.setResizable(false);
    this.setTitle("                          Consulter Etudiant    :");
    this.addWindowListener(new java.awt.event.WindowAdapter() {
      public void windowOpened(WindowEvent e) {
        this_windowOpened(e);
      }
    });
    jbtnRetour.setBounds(new Rectangle(146, 315, 120, 36));
    jbtnRetour.setFont(new java.awt.Font("Dialog", 1, 13));
    jbtnRetour.setHorizontalTextPosition(SwingConstants.LEFT);
    jbtnRetour.setIcon(new ImageIcon(new java.net.URL("file:///G:/Documents and Settings/Administrateur/Bureau/Projet Gestion des Note Graphique V3A/Projet Gestion des Note2/retour.gif")));
    jbtnRetour.setText("Retour");
    jbtnRetour.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(ActionEvent e) {
        jbtnRetour_actionPerformed(e);
      }
    });
    jbtnRetour.addMouseListener(new java.awt.event.MouseAdapter() {
      public void mouseEntered(MouseEvent e) {
        jbtnRetour_mouseEntered(e);
      }
      public void mouseExited(MouseEvent e) {
        jbtnRetour_mouseExited(e);
      }
    });
    this.getContentPane().add(jPanel1, BorderLayout.CENTER);
    jPanel1.add(jLabel1, null);
    jPanel1.add(jLabel2, null);
    jPanel1.add(jLabel3, null);
    jPanel1.add(jLabel4, null);
    jPanel1.add(jLabel5, null);
    jPanel1.add(jLabel6, null);
    jPanel1.add(jlblMatricule, null);
    jPanel1.add(jlblNom, null);
    jPanel1.add(jlblPrénom, null);
    jPanel1.add(jlblGroup, null);
    jPanel1.add(jlblFilier, null);
    jPanel1.add(jPanel2, null);
    jPanel1.add(jbtnRetour, null);
  }

  void this_windowOpened(WindowEvent e) {

Etudiant etd1 = new Etudiant();
int mt;
String mtr1=JOptionPane.showInputDialog(null,"Veuillez saisir le Matricule d'etudiant à modifier:   ","Gestion carnet de notes",JOptionPane.QUESTION_MESSAGE);
if(!((mtr1==null) || mtr1.equals("")))
{
mt=Integer.valueOf(mtr1.trim()).intValue();
etd1=cls.Recherche(mt);
if(etd1==null)
{
   JOptionPane.showMessageDialog(null,"      Etudiant non existe","Gestion carnet de notes",JOptionPane.INFORMATION_MESSAGE);
   Retour();
}
else{
   jlblMatricule.setText(String.valueOf(etd1.getMatricle()));
   jlblNom.setText(etd1.getNom());
   jlblPrénom.setText(etd1.getPrenom());
   jlblFilier.setText(etd1.getFilier());
   jlblGroup.setText(String.valueOf(etd1.getGroup()));
   for (int i = 0; i < 3; i++) {
     jlblNote1[i].setText(String.valueOf(etd1.getnot(i)));
   }
 }

}
  else
   Retour();
  }

  void jbtnRetour_mouseEntered(MouseEvent e) {
setCursor(new Cursor(12));
  }

  void jbtnRetour_mouseExited(MouseEvent e) {
setCursor(new Cursor(0));
  }

  void jbtnRetour_actionPerformed(ActionEvent e) {
Retour();
  }
  public void Retour(){
   dispose() ;
  }
}
